<template>
  <div class="app-container">
    <div class="zd3">
      <div class="zd3-title">
        <p>
          <span>履职内容</span>
          <input v-model="resultContent" type="text" placeholder="请输入履职内容" />
        </p>
        <h3 @click="seach">查询</h3>
        <h4 @click="resetList">重置</h4>
				<h3 @click="addpeople" style="background: #0093FF">新增</h3>
      </div>
      <el-tabs v-model="activeName" @tab-click="handleClick" class="all">
        <el-tab-pane name="zhengchang">
          <span slot="label">正常履职</span>
          <div class="zd3-btm">
            <el-table
              :data="zctableData"
              style="width: 100%;border-radius: 8px;"
              :show-header="showHeader"
              v-loading="loading"
            >
              <el-table-column type="index" align="center" label="序号" width="80" />
              <el-table-column align="center" label="履职状态" width="80" >
                <template slot-scope="scope">
                  <div class="status" :class="scope.row.status === '4' ? 'red': scope.row.status === '2' ? 'yellow' : scope.row.status === '3' ? 'red' : scope.row.status === '1' ? 'blue' : 'green'">{{scope.row.status === '4' ? '异常履职' : scope.row.status === '2' ? '履职中' : scope.row.status === '3' ? '超时履职' : scope.row.status === '1' ? '问题结束' : '正常履职'}}</div>
                </template>
              </el-table-column>
              <el-table-column align="center" label="履职内容" prop="resultContent" />
              <el-table-column align="center" label="履职人员" prop="resultPerson" />
              <el-table-column align="center" label="履职时间" prop="resultTimes" />
              <el-table-column align="center" label="履职图片">
                <template slot-scope="scope">
                  <img :src="scope.row.resultUrl" alt="" class="s-img">
                </template>
              </el-table-column>
              <el-table-column align="center" width="220" label="操作">
                <template slot-scope="scope">
                  <el-button type="text" size="small" @click="look(scope.row,scope.$index)">查看</el-button>
                  <el-button type="text" size="small" @click="write(scope.row,scope.$index)">编辑</el-button>
                  <el-button v-if="scope.row.status === '4'" type="text" size="small" @click="chuli(scope.row,scope.$index)">处理</el-button>
                  <el-popconfirm
                    placement="top"
                    hideIcon
                    title="是否要删除此行？"
                    @onConfirm="deleteRow(scope.row)"
                  >
                    <el-button type="text" size="small" slot="reference">删除</el-button>
                  </el-popconfirm>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-tab-pane>
        <el-tab-pane name="yichang">
          <span slot="label">异常履职</span>
          <div class="zd3-btm">
            <el-table
              :data="yctableData"
              style="width: 100%;border-radius: 8px;"
              :show-header="showHeader"
              v-loading="loading"
            >
              <el-table-column type="index" align="center" label="序号" width="80" />
              <el-table-column align="center" label="履职状态" width="80" >
                <template slot-scope="scope">
                  <div class="status" :class="scope.row.status === '4' ? 'red': scope.row.status === '2' ? 'yellow' : scope.row.status === '3' ? 'red' : scope.row.status === '1' ? 'blue' : 'green'">{{scope.row.status === '4' ? '异常履职' : scope.row.status === '2' ? '履职中' : scope.row.status === '3' ? '超时履职' : scope.row.status === '1' ? '问题结束' : '正常履职'}}</div>
                </template>
              </el-table-column>
              <el-table-column align="center" label="履职内容" prop="contents" />
              <el-table-column align="center" label="问题所属" prop="chejianName" />
              <el-table-column align="center" label="履职人员" prop="rpersons" />
              <el-table-column align="center" label="履职时间" prop="normalTime" />
              <!-- <el-table-column align="center" label="问题" >
                <template slot-scope="scope">
                  <div class="ellisp">{{scope.row.problems}}</div>
                </template>
              </el-table-column> -->
              <el-table-column align="center" label="履职图片">
                <template slot-scope="scope">
                  <img :src="scope.row.imgurls" alt="" class="s-img">
                </template>
              </el-table-column>
              <el-table-column align="center" width="220" label="操作">
                <template slot-scope="scope">
                  <el-button type="text" v-if="scope.row.status !== '1'" size="small" @click="chuli(scope.row,scope.$index)">处理</el-button>
                  <el-button type="text" size="small" @click="look(scope.row,scope.$index)">查看</el-button>
                  <el-button type="text" size="small" @click="write(scope.row,scope.$index)">编辑</el-button>
                  <el-popconfirm
                    placement="top"
                    hideIcon
                    title="是否要删除此行？"
                    @onConfirm="deleteRow(scope.row)"
                  >
                    <el-button type="text" size="small" slot="reference">删除</el-button>
                  </el-popconfirm>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>

<script>
let classifyId = null;
import{ uploadFile } from '@/api/people'
import { selectProblemResult,deleteProblemResult } from "@/api/oneclassify"
export default {
  data() {
    return {
      content: "",
      total: 1,
      page: 1,
      showHeader: true,
      loading: true,
      zctableData: [],
      yctableData: [],
      dialogVisible: false,
      tempData: {},
      tempIndex: -1,
      boxshow: false,
      resultContent: '',
      activeName: 'zhengchang'
    };
  },
  mounted() {
    const temp = JSON.parse(localStorage.getItem('lvzhi'))
    console.log(temp)
    classifyId = temp.fid
    this.getzcList(temp.fid);
    this.getycList(temp.fid);
  },
  methods: {
    seach(){
      this.getList(classifyId,this.resultContent)
    },
    getzcList(id,reslut) {
      selectProblemResult({
        parentId: id,
        resultContent: reslut
      }).then(res => {
        console.log(res);
        this.zctableData = res.data
        this.loading = false;
      });
    },
    getycList(id,reslut) {
      selectProblemResult({
        tijiaoMulv: id,
        resultContent: reslut
      }).then(res => {
        console.log(res);
        this.yctableData = res.data
        this.loading = false;
      });
    },
    handleClick(e){
      console.log(e)
    },
    /**
     * 编辑问题
     */
    write(item, index) {
      this.$router.push({
        name: 'Writelvzhi',
        params: {
          options: JSON.stringify(item),
          fatherId: classifyId
        }
      })
    },
    /**
     * 处理问题
     */
    chuli(item){
      this.$router.push({
        name: 'Chuli',
        params: {
          options: JSON.stringify(item)
        }
      })
    },
    deleteRow(item) {
      console.log(item) 
      console.log("删除");
      deleteProblemResult(item.rid).then(res => {
        console.log(res);
        this.$message({
          showClose: true,
          message: res.message,
          type: "success"
        });
        this.getList(classifyId);
      });
    },
    look(item){
      this.$router.push({
        name: 'Lookproblem',
        params: {
          options: JSON.stringify(item)
        }
      })
    },
    goPrev(page) {
      console.log(page)
      this.page--
      this.getList(classifyId)
    },
    goNext(page) {
      console.log(page)
      this.page++
      this.getList(classifyId)
    },
    goPage(page){
      console.log(page)
      this.page = page
      this.getList(classifyId)
    },
    designUpAvatar(item){
      console.log(this.fileNum)
      var formData = new FormData()
      const loading = this.$loading({
        lock: true,
        text: '上传中请稍等...',
        spinner: 'el-icon-loading',
        background: 'rgba(255, 255, 255, 0.8)'
      })
      formData.append("file", item.file)
      uploadFile(formData).then(res => {
        console.log(res)
        this.$message({
          showClose: true,
          message: '添加成功',
          type: "success"
        })
        loading.close()
        // this.imageUrl = res
        this.tempData.imgurl = res
        this.$forceUpdate()
      }).catch(() => {
        loading.close()
      })
    },
    resetList() {
      this.content = "";
    },
    addpeople() {
      this.$router.push({
        name:'Writelvzhi',
        params: {
          fatherId: classifyId
        }
      })
    }
  }
};
</script>

<style lang="scss" scoped>
/deep/.el-tabs__item.is-active {
  color: #18a05e;
}
/deep/.el-tabs__active-bar {
  background-color: #18a05e;
}
/deep/.el-tabs__item:hover {
  color: #18a05e;
  cursor: pointer;
}
.all{
  background: #fff;
  padding: 5px 20px 20px 20px;
  border-radius: 10px;
  margin-top: 20px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}
.avatar-uploader{
  position: relative;
}
.status{
  width: 70px;
  height: 27px;
  margin: 0;
  padding: 0;
  border-radius: 5px;
  text-align: center;
  line-height: 27px;
  color: #fff;
  font-size: 12px
}
.red{
  background: #ff0000;
}
.green{
  background: #18a05e;
}
.yellow{
  background: #c7ba03;
}
.blue{
  background: #078fff;
}
.avatar-uploader .el-upload {
  border: 1px dashed #999 !important;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  width: 100%;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatars{
	width: 45px;
	height: 45px;
  margin: 0 auto;
  border: 1px solid #ccc
}

.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 100px;
  height: 100px;
	border: 1px dashed #CCCCCC;
  line-height: 100px;
  text-align: center;
}
.avatar {
  width: 100px;
  height: 100px;
  display: block;
}
/deep/.el-button--primary {
  color: #fff;
  background-color: #18a05e !important;
  border-color: #18a05e !important;
}
/deep/.el-button--primary:hover,
.el-button--primary:focus {
  background: #18a05e !important;
  border-color: #18a05e !important;
  color: #fff !important;
}
/deep/.el-button:hover,
.el-button:focus {
  color: #18a05e;
  background-color: transparent;
}
/deep/.el-button--primary {
  color: #fff;
  background-color: #18a05e;
  border-color: #18a05e;
}
/deep/.el-button--text {
  color: #00c666 !important;
}
.ellisp{
	width: 100%;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	overflow: hidden;
	text-align: left;
}
.app-container {
  padding: 10px;
}
.rolestip {
  width: 100%;
  display: flex;
  justify-content: center;
}
.inps {
  width: 100%;
  height: 32px;
  line-height: 32px;
  padding-left: 10px;
  background: none;
  border: none;
  color: #333;
}
.inps-active {
  width: 100%;
  height: 32px;
  line-height: 32px;
  padding-left: 10px;
  // background:#ccc;
  border: none;
  color: #333;
}
.s-img{
  width: 80px;
  height: 80px;
}
.zd3-title {
	height: 80px;
	display: flex;
	align-items: center;
	padding: 0 20px;
	position: relative;
	background: #ffffff;
	border-radius: 8px;
	border: 1px solid rgba(0, 0, 0, 0.1);

	> p {
		font-size: 14px;
		color: #333;
		margin-right: 30px;

		> span {
			padding-right: 20px;
		}

		> input {
			width: 200px;
			height: 32px;
			// background: #ccc;
			border-radius: 3px;
			border: 1px solid #ccc;
			padding-left: 10px;
			color: #333;
		}
	}

	> h3 {
		width: 64px;
		height: 32px;
		background: #18a05e;
		border-radius: 3px;
		margin: 0 30px 0 0;
		color: #fff;
		font-size: 14px;
		line-height: 32px;
		font-weight: 100;
		text-align: center;
		cursor: pointer;
	}

	> h4 {
		width: 64px;
		height: 32px;
		border-radius: 3px;
		border: 1px solid rgba(0, 0, 0, 0.1);
		color: #333;
		font-size: 14px;
		line-height: 32px;
		font-weight: 100;
		text-align: center;
		cursor: pointer;
		margin-right: 30px;
	}
}
/deep/.el-pagination.is-background .el-pager li:not(.disabled).active {
  background-color: #18a05e;
  color: #fff;
}
.zd3-btm /deep/.btn-prev:after {
  content: "上一页";
}
.zd3-btm /deep/.btn-next:before {
  content: "下一页";
}
.zd3-btm /deep/.btn-prev,
.zd3-btm /deep/.btn-next {
  width: 65px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}
.zd3-btm {
  background: rgba(255, 255, 255, 1);
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  // margin-top: 20px;
  overflow: hidden;
  &-title {
    display: flex;
    align-items: center;
    height: 70px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    background: #ffffff;
    > p {
      text-align: center;
      font-size: 16px;
      color: #333;
    }
  }
  .el-pagination {
		white-space: nowrap;
		padding: 15px 5px;
		color: #303133;
		font-weight: bold;
	}
  .addDate {
    margin: 20px 32px 10px 32px;
    height: 32px;
    border-radius: 3px;
    text-align: center;
    line-height: 32px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    border: 1px dashed rgba(0, 0, 0, 0.25);
  }
  .el-button--text {
    margin: 0 5px;
  }
}
.change {
  display: flex;
  flex-wrap: wrap;
  > p {
    width: 50%;
    font-size: 14px;
    display: flex;
    align-items: center;
    color: #333;
    /deep/.el-input__inner {
      width: inherit;
      background: none;
      height: 32px;
      // line-height: 32px;
      color: #333;
      border: 1px solid rgba(0, 0, 0, 0.1);
      padding: 0 25px;
    }
    /deep/.el-input__icon {
      line-height: 32px;
    }
    .userselect {
      // max-width: 250px;
      flex: 1;
    }

    > span {
      display: block;
      width: 120px;
      text-align: right;
      padding-right: 15px;
    }
    > input {
      width: inherit;
      flex: 1;
      height: 32px;
      border-radius: 3px;
      border: 1px solid rgba(0, 0, 0, 0.1);
      padding-left: 10px;
      color: #333;
    }
  }
}
</style>
